package com.org.oracle.controller;

import com.org.oracle.mongodb.dto.UserLoginDTO;
import com.org.oracle.mongodb.dto.UserModifyInfoDTO;
import com.org.oracle.result.Result;
import com.org.oracle.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 * @author: heiye
 * @date: 2024/10/09 下午9:14
 * @version: v1.0.0
 * @description: 用户接口
 */
@RestController
@RequestMapping("/user")
public class UserController {


    @Resource
    private UserService userService;

    /**
     * 用户登录
     *
     * @param dto
     * @return
     */
    @PostMapping("/wxLogin")
    public Result wxLogin(@RequestBody UserLoginDTO dto) {
        return userService.wxLogin(dto);
    }

    /**
     * 用户信息更改
     *
     * @param dto
     * @return
     */
    @PostMapping("/modifyInfo")
    public Result modifyInfo(@RequestHeader String uid, @RequestBody UserModifyInfoDTO dto) {
        return userService.modifyInfo(uid, dto);
    }

    /**
     * 基于用户id查找用户信息
     *
     * @return
     */
    @GetMapping("/findById")
    public Result findUserById(@RequestHeader String uid) {
        return userService.findUserById(uid);
    }
}

